<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>服务派工管理系统管理后台</title>
  <link rel="stylesheet" href="${basePath}/admin/layui/css/layui.css?v=${viersion}">
  <link rel="stylesheet" href="${basePath}/admin/css/admin.css?v=${viersion}">
	<link rel="stylesheet" href="${basePath}/admin/js/lightbox/css/lightbox.min.css?v=${viersion}" />
  <script type="text/javascript">
  	window.basePath = '${basePath}';
  	window.version = '${viersion}';
  	window.empName = '${sessionScope.employees.empName}';
  	window.empCode = '${sessionScope.employees.empCode}';
  	window.empDept = '${sessionScope.employees.orgName}';
		window.token = '${sessionScope.token}';
  </script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo">
		<img  class="admin-logo" src="${basePath }/admin/images/logo.png">
	</div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <ul class="layui-nav layui-layout-left" lay-filter="mytopnav" id="mytopnav">
   	 <li class="layui-nav-item layadmin-flexible" lay-unselect="">
        <a href="javascript:;" layadmin-event="flexible" title="侧边伸缩">
          <i class="layui-icon layui-icon-spread-left" id="LAY_app_flexible"></i>
        </a>
      </li>
      <li class="layui-nav-item layui-nav-itemed"><a href="javascript:;" id="index_home" data-url="console">控制台</a></li>
      <li class="layui-nav-item"><a href="javascript:;" data-url="/orders/orders">工单处理</a></li>
    </ul>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item">
        <a href="javascript:;" id="userName">
        </a>
        <dl class="layui-nav-child">
          <%--<dd><a href="">修改密码</a></dd>--%>
          <dd><a href="${basePath }/admin/outLogin">退出登录</a></dd>
        </dl>
      </li>
    </ul>
  </div>
  
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll layui-bg-cyan">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree layui-bg-cyan"  lay-filter="mynav" id="mynav">
      </ul>
    </div>
  </div>
  
  <div class="layui-body" id="index_right">
  </div>
  
 <!--  <div class="layui-footer">
  </div> -->
</div>
 
<script src="${basePath}/admin/layui/layui.all.js?v=${viersion}"></script>
<script src="${basePath}/admin/js/plugin/jquery-2.2.4.min.js?v=${viersion}"></script>
<script src="${basePath}/admin/js/plugin/template-web.js?v=${viersion}"></script>
<script src="${basePath}/admin/js/mylayui.js?v=${viersion}"></script>
<script src="${basePath}/admin/js/lightbox/js/lightbox-plus-jquery.min.js?v=${viersion}"></script>
<script src="${basePath}/admin/js/index.min.js?v=${viersion}"></script>
<script src="https://webapi.amap.com/maps?v=1.4.8&key=83d2a8f1731ffd9706874206a8b5989f"></script>
<script>
//由于模块都一次性加载，因此不用执行 layui.use() 来加载对应模块，直接使用即可：
$(function(){
  var layer = layui.layer;
  var element = layui.element;
  
  var index = layer.load(3);

  $("#userName").html(window.empName);

  $.ajax({
		url: window.basePath + "/sys/findMenuByUserId",
		type: "POST",
		dataType: 'json',
		headers: {"token" : window.token},
		data:{empCode:window.empCode},//暂时写死
		success: function(data) {
			var leftObjArr = data.leftData;
			var topObjArr = data.topData;
			for(var i=0;i<leftObjArr.length;i++){
				var rowObj = leftObjArr[i];
				var parent = rowObj.parent;
				var subArr = rowObj.sub;
				var appendEle = "";
				if(i==0){
					appendEle += "<li class='layui-nav-item layui-nav-itemed'>";
				}else{
					appendEle += "<li class='layui-nav-item'>";
				}
				appendEle += "<a class='' href='javascript:;'>"+
									"<i class='layui-icon "+parent.menuIcon+"' style='margin-right: 10px;'></i>"+
									"<cite>"+parent.menuName+"</cite>"+
							  "</a>";
			    appendEle += "<dl class='layui-nav-child'>";				  
				for(var j=0;j<subArr.length;j++){
					appendEle += "<dd><a href='javascript:;' data-url='"+subArr[j].menuUrl+"'><i class='layui-icon "+subArr[j].menuIcon+"' style='margin-right: 10px;'></i>"+subArr[j].menuName+"</a></dd>";
				}
				appendEle += "</dl>";
				appendEle += "</li>";
				$("#mynav").append(appendEle);
			}
			for(var i=0;i<topObjArr.length;i++){
				var rowObj = topObjArr[i];
				var parent = rowObj.parent;
				var subArr = rowObj.sub;
				var appendEle = "";
				if(i==0){
					appendEle += "<li class='layui-nav-item'>";
				}else{
					appendEle += "<li class='layui-nav-item'>";
				}
				appendEle += "<a href='javascript:;'>"+parent.menuName+
							  "</a>";
			    appendEle += "<dl class='layui-nav-child'>";				  
				for(var j=0;j<subArr.length;j++){
					appendEle += "<dd><a href='javascript:;' data-url='"+subArr[j].menuUrl+"'>"+subArr[j].menuName+"</a></dd>";
				}
				appendEle += "</dl>";
				appendEle += "</li>";
				$("#mytopnav").append(appendEle);
			}
			//对导航栏重新渲染
		    element.render("nav", "mynav");
		    element.render("nav", "mytopnav");
		    
		    layer.close(index);
		},
		error:function(){
			layer.close(index);
			layer.alert("操作失败");
		}
	});
});

</script> 
</body>
</html>